<template>
<section v-loading="list_loading">
  <div class="searchbox">
      <el-form inline :model="query"  class="demo-form-inline fl">
        <el-form-item>
          <el-input size="medium" v-model="query.k" placeholder="学员姓名或手机号"></el-input>
        </el-form-item>
        <el-form-item>
          <el-select size="medium" v-model="query.kemu" placeholder="按科目查找">
            <el-option label="全部科目" value=""></el-option>
            <el-option label="未报名" value="0"></el-option>
            <el-option label="科目一" value="1"></el-option>
            <el-option label="科目二" value="2"></el-option>
            <el-option label="科目三" value="3"></el-option>
            <el-option label="科目四" value="4"></el-option>
            <el-option label="已毕业" value="100"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select size="medium" v-model="query.taocan" placeholder="按套餐查找">
            <el-option label="全部套餐" value=""></el-option>
            <template v-for="item in taocanData">
              <el-option :label="item.title" :value="item.id"></el-option>
            </template>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small" icon="el-icon-search" @click="doSearch">搜&nbsp;&nbsp;索</el-button>
        </el-form-item>
      </el-form>
      <el-button type="primary" size="small" class="fr" icon="el-icon-plus" @click.stop="userForm.addShow=true">添加学员</el-button>
  </div>
  <div @contextmenu="$parent.addMenu([{name:'刷新学员列表',method:'getData',icon:'icon-shuaxin'}])">
      <el-table ref="multipleTable" :data="listData" tooltip-effect="dark" highlight-current-row style="width: 100%;text-align:center" @row-click="openSidebar" @selection-change="rowSelect">
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="id" label="学员ID"></el-table-column>
        	<el-table-column prop="real_name" label="姓名"></el-table-column>
          <el-table-column label="姓别">
            <template slot-scope="scope">
                <span v-if="scope.row.sex==0">未知</span>
                <i v-else-if="scope.row.sex==1" class="iconfont icon-nanxing" style="color:#31C8A4"></i>
                <i v-else="scope.row.sex==2" class="iconfont icon-nvxing" style="color:#FA5555"></i>
            </template>
          </el-table-column>
        	<el-table-column prop="mobile" label="手机号"></el-table-column>
          <el-table-column prop="taocan" label="套餐"></el-table-column>
          <el-table-column prop="coach" label="归属教练"></el-table-column>
          <el-table-column label="进度">
            <template slot-scope="scope">{{ scope.row.kemu|kemu }}</template>
          </el-table-column>
      </el-table>
      <div class="breakpage" v-if="page.total>0">
        <el-select size="medium" v-model="progress" placeholder="批量修改进度" @change="changeProgress" style="float:left;width:150px">
          <el-option label="未报名" value="0"></el-option>
          <el-option label="科目一" value="1"></el-option>
          <el-option label="科目二" value="2"></el-option>
          <el-option label="科目三" value="3"></el-option>
          <el-option label="科目四" value="4"></el-option>
          <el-option label="已毕业" value="100"></el-option>
        </el-select>
        <el-pagination background layout="total,sizes,prev, pager, next"
            :total="parseInt(page.total)"
            :page-size="parseInt(page.pagesize)"
            :current-page="parseInt(page.curpage)"
            @size-change="sizeChange"
            @current-change="pageChange">
        </el-pagination>
      </div>
  </div>
    <!--侧边栏-->
    <transition name="slide-fade">
  	  <div v-show="sidebar.show" class="sidebar" v-loading="sidebar.loading" @contextmenu="$parent.addMenu([{name:'关闭侧边栏',method:'closeSidebar',icon:'icon-guanbi'}])">
  	    <el-tabs class="user_side" @tab-click="tabChange" value="info">
  			  <el-tab-pane label="学员信息" name="info">
            <div v-if="sidebar.info" class="coach-infor" @contextmenu="$parent.addMenu([{name:'刷新学员信息',method:'getSideData=info',icon:'icon-shuaxin'}])">
            		<ul>
            			<li class="clearfix"><span class="coach-att">姓名</span><span class="coach-val">{{sidebar.info.real_name}}</span></li>
            			<li class="clearfix"><span class="coach-att">手机号</span><span class="coach-val">{{sidebar.info.mobile}}</span></li>
            			<li class="clearfix"><span class="coach-att">身份证号</span><span class="coach-val">{{sidebar.info.id_number}}</span></li>
                  <li class="clearfix"><span class="coach-att">指导教练</span><span class="coach-val">{{sidebar.info.coach}}</span></li>
            			<li class="clearfix"><span class="coach-att">学车进度</span><span class="coach-val">{{sidebar.info.kemu|kemu}}</span></li>
                  <li class="clearfix"><span class="coach-att">资金</span><span class="coach-val">{{sidebar.info.money}}元</span></li>
                  <li class="clearfix"><span class="coach-att">冻结资金</span><span class="coach-val">{{sidebar.info.frozen_money}}元</span></li>
            			<li class="clearfix"><span class="coach-att">状态</span><span class="coach-val">正常</span></li>
            			<li class="clearfix"><span class="coach-att">注册时间</span><span class="coach-val">{{sidebar.info.regtime|date('Y-m-d')}}</span></li>
            			<li class="clearfix"><span class="coach-att">登录时间</span><span class="coach-val">{{sidebar.info.lasttime|date('Y-m-d')}}</span></li>
            			<li class="clearfix" v-if="sidebar.info.file" style="height:120px;"><span class="coach-att">教练资料</span>
            			<div class="coach-img clearfix">
            					<img v-for="path in sidebar.info.file" :src="path" style="cursor:pointer" @click.stop='imgPreview({url:path})'>
            			</div>
            			</li>
                  <li class="clearfix"><span class="coach-att">&nbsp;</span><el-button type="primary" size="small" @click.stop="editUser">编 &nbsp; 辑</el-button></li>
            		</ul>
	          </div>
  			  </el-tab-pane>
  			  <el-tab-pane label="预约信息" name="bookList">
            <div @contextmenu="$parent.addMenu([{name:'刷新预约信息',method:'getSideData=bookList',icon:'icon-shuaxin'}])">
              <el-table :data="sidebar.bookList" style="width: 100%;text-align:center">
                <el-table-column label="预约时间">
                  <template slot-scope="scope">{{ scope.row.book_time+':00-'+scope.row.book_time+':59' }}</template>
                </el-table-column>
                <el-table-column label="预约科目">
                  <template slot-scope="scope">{{ scope.row.book_kemu|kemu }}</template>
                </el-table-column>
                <el-table-column prop="coach_name" label="指导教练"></el-table-column>
                <el-table-column label="学车状态">
                  <template slot-scope="scope">
                    <font v-if="scope.row.status==0">已预约</font>
                    <font color="#31C8A4" v-else-if="scope.row.status==1">已结课</font>
                    <font color="grey" v-else-if="scope.row.status==2">已取消</font>
                    <font v-else-if="scope.row.status==3">教练请假</font>
                    <font color="red" v-else-if="scope.row.status==4">旷课</font>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
  			  <el-tab-pane label="学车进度" name="progress">
            <div class="student-pro" @contextmenu="$parent.addMenu([{name:'刷新学车进度',method:'getSideData=progress',icon:'icon-shuaxin'}])">
                <div class="stu-year" v-if="sidebar.progress[0]">
                  <img src="../assets/pro-year2@v2.png">
                  <div class="pro-link"></div>
                  <p>{{sidebar.progress[0].create_time|date('Y')}}</p>
                </div>
                <div class="pro-con" v-if="sidebar.progress[0]">
                  <div v-for="(item,index) in sidebar.progress" class="stu_list clearfix">
                   <div class="number">
                      <div class="number-con"><img src="../assets/pro-img@v2.png"></div>
                      <div class="number_link"></div>
                      <div v-if="sidebar.progress.length==index+1" class="cricle"></div>
                   </div>
                   <div class="year-list" :class="index%2==0?'pro-right':''">
                      <p class="data">{{item.create_time|date("Y-m-d")}}</p>
                      <p class="data-name">{{item.info}}</p>
                   </div>
                  </div>
               </div>
            </div>
          </el-tab-pane>
  			  <el-tab-pane label="交易记录" name="account">
            <div style="overflow:auto" @contextmenu="$parent.addMenu([{name:'刷新交易记录',method:'getSideData=account',icon:'icon-shuaxin'}])">
              <el-table :data="sidebar.account" style="width: 100%;text-align:center">
                  <el-table-column label="时间">
                    <template slot-scope="scope">{{ scope.row.regtime|date('Y-m-d H:i') }}</template>
                  </el-table-column>
                  <el-table-column prop="user_balance" label="资金余额" width="180"></el-table-column>
                  <el-table-column label="收入/支出">
                    <template slot-scope="scope">
                        <font v-if="scope.row.change_type==1" style="color:green">+{{ scope.row.deal_amount }}</font>
                        <font v-else style="color:red">-{{ scope.row.deal_amount }}</font>
                    </template>
                  </el-table-column>
                  <el-table-column prop="deal_name" label="交易类型"></el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
        </el-tabs>
  	  </div>
    </transition>
    <div v-if="sidebar.show" class="v-modal" @click="closeSidebar"></div>
    <!--侧边栏-->
    <!--编辑学员弹窗-->
    <el-dialog title="编辑学员" :visible.sync="userForm.editShow" @close="closeDialog" width="600px">
      <el-form :model="userForm.data" :rules="rules1" ref="edit" label-width="80px">
      <el-form-item label="姓名" prop="real_name">
        <el-input v-model="userForm.data.real_name" placeholder="请输入学员姓名"></el-input>
      </el-form-item>
      <el-form-item label="手机号" prop="mobile">
        <el-input v-model="userForm.data.mobile" placeholder="请输入学员手机号"></el-input>
      </el-form-item>
      <el-form-item label="身份证号" prop="id_number">
        <el-input v-model="userForm.data.id_number" placeholder="请输入学员身份证号"></el-input>
      </el-form-item>
      <el-form-item label="学车进度">
          <el-select v-model="userForm.data.kemu" placeholder="请选择科类">
            <el-option label="未报名" value="0"></el-option>
            <el-option label="科目一" value="1"></el-option>
            <el-option label="科目二" value="2"></el-option>
            <el-option label="科目三" value="3"></el-option>
            <el-option label="科目四" value="4"></el-option>
            <el-option label="已毕业" value="100"></el-option>
          </el-select>
      </el-form-item>
      <el-form-item label="上传资料">
        <el-upload class="file-uploader" :action="$parent.uploadUrl" :headers="{token:$parent.token}" accept="image/*" :show-file-list="false" name="img_1" :on-success="uploadSuccess">
            <div v-if="userForm.data.file&&userForm.data.file.img_1" class="avatar" @click.stop>
                 <img :src="userForm.data.file.img_1" ><p>身份证正面</p>
                 <span class="file_item_action">
                    <i class="el-icon-zoom-in" @click.stop='imgPreview({url:userForm.data.file.img_1})'></i>
                    <i class="el-icon-delete" @click.stop='removeFile("img_1")'></i>
                 </span>
            </div>
            <div v-else><i class="el-icon-plus avatar-uploader-icon"></i><p>身份证正面</p></div>
        </el-upload>
        <el-upload class="file-uploader" :action="$parent.uploadUrl" :headers="{token:$parent.token}" accept="image/*" name="img_2" :show-file-list="false" :on-success="uploadSuccess">
            <div v-if="userForm.data.file&&userForm.data.file.img_2" class="avatar" @click.stop>
                 <img :src="userForm.data.file.img_2" ><p>身份证反面</p>
                 <span class="file_item_action">
                    <i class="el-icon-zoom-in" @click.stop='imgPreview({url:userForm.data.file.img_2})'></i>
                    <i class="el-icon-delete" @click.stop='removeFile("img_2")'></i>
                 </span>
            </div>
            <div v-else><i  class="el-icon-plus avatar-uploader-icon"></i><p>身份证反面</p></div>
        </el-upload>
      </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="userForm.editShow = false">取 消</el-button>
        <el-button size="small" type="primary" @click.stop="submitUserForm('edit')" v-loading="userForm.loading">保 存</el-button>
      </div>
    </el-dialog>
    <!--添加弹窗-->
    <el-dialog title="添加学员" :visible.sync="userForm.addShow" width="650px">
      <div style="width:550px;margin:10px auto 0">
        <el-steps :active="userForm.active" finish-status="finish" style="margin-bottom:30px">
            <el-step title="基本信息"></el-step>
            <el-step title="选择套餐"></el-step>
            <el-step title="报名成功"></el-step>
        </el-steps>
        <el-form v-if="userForm.active==1" :model="userForm.data" :rules="rules1" ref="add" label-width="80px" style="width:450px;margin:0 auto">
            <el-form-item label="姓名" prop="real_name">
              <el-input v-model="userForm.data.real_name" placeholder="请输入学员姓名"></el-input>
            </el-form-item>
            <el-form-item label="手机号" prop="mobile">
              <el-input v-model="userForm.data.mobile" @change="checkMobile" placeholder="请输入学员手机号"></el-input>
            </el-form-item>
            <el-form-item label="身份证号" prop="id_number">
              <el-input v-model="userForm.data.id_number" placeholder="请输入学员身份证号"></el-input>
            </el-form-item>
            <el-form-item label="学车进度">
                <el-select v-model="userForm.data.kemu" placeholder="请选择科类">
                  <el-option label="未报名" value="0"></el-option>
                  <el-option label="科目一" value="1"></el-option>
                  <el-option label="科目二" value="2"></el-option>
                  <el-option label="科目三" value="3"></el-option>
                  <el-option label="科目四" value="4"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="上传资料">
              <el-upload class="file-uploader" :action="$parent.uploadUrl" :headers="{token:$parent.token}" accept="image/*" :show-file-list="false" name="img_1" :on-success="uploadSuccess">
                  <div v-if="userForm.data.file&&userForm.data.file.img_1" class="avatar" @click.stop>
                       <img :src="userForm.data.file.img_1" ><p>身份证正面</p>
                       <span class="file_item_action">
                          <i class="el-icon-zoom-in" @click.stop='imgPreview({url:userForm.data.file.img_1})'></i>
                          <i class="el-icon-delete" @click.stop='removeFile("img_1")'></i>
                       </span>
                  </div>
                  <div v-else><i class="el-icon-plus avatar-uploader-icon"></i><p>身份证正面</p></div>
              </el-upload>
              <el-upload class="file-uploader" :action="$parent.uploadUrl" :headers="{token:$parent.token}" accept="image/*" name="img_2" :show-file-list="false" :on-success="uploadSuccess">
                  <div v-if="userForm.data.file&&userForm.data.file.img_2" class="avatar" @click.stop>
                       <img :src="userForm.data.file.img_2" ><p>身份证反面</p>
                       <span class="file_item_action">
                          <i class="el-icon-zoom-in" @click.stop='imgPreview({url:userForm.data.file.img_2})'></i>
                          <i class="el-icon-delete" @click.stop='removeFile("img_2")'></i>
                       </span>
                  </div>
                  <div v-else><i  class="el-icon-plus avatar-uploader-icon"></i><p>身份证反面</p></div>
              </el-upload>
            </el-form-item>
        </el-form>
        <el-form v-if="userForm.active==2" :model="userForm.pay" :rules="rules2" ref="pay" label-width="80px" style="width:450px;margin:0 auto">
            <el-form-item label="选择套餐" prop="taocan_id">
                <el-select v-model="userForm.pay.taocan_id" placeholder="请选择套餐" @change="changeTaocan" style="width:100%">
                  <template v-for="item in taocanData">
                    <el-option :label="item.title+'-'+item.price+'元'" :value="item.id"></el-option>
                  </template>
                </el-select>
            </el-form-item>
            <el-form-item label="学费总额" prop="taocan_price">
              <el-input v-model="userForm.pay.taocan_price" placeholder="请输入学费总额"></el-input>
            </el-form-item>
            <el-form-item label="实收金额" prop="has_pay">
              <el-input v-model="userForm.pay.has_pay" placeholder="请输入本次实收金额"></el-input>
            </el-form-item>
            <el-form-item label="支付方式" prop="pay_type">
                <el-select v-model="userForm.pay.pay_type" placeholder="请选择支付方式">
                  <el-option label="微信支付" value="1"></el-option>
                  <el-option label="支付宝" value="2"></el-option>
                  <el-option label="现金" value="3"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" :rows="3"  placeholder="备注信息" v-model="userForm.pay.remark"></el-input>
            </el-form-item>
        </el-form>
        <div v-if="userForm.active==3" style="text-align:center;color:#31C8A4;padding:30px 0">
          <i class="el-icon-circle-check-outline" style="font-size:70px"></i>
          <h3>恭喜您，报名成功</h3>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="userForm.active<=2" size="small" @click="preStep">{{userForm.active==1?'取 消':'上 一 步'}}</el-button>
        <el-button size="small" type="primary" @click.stop="nextStep" v-loading="userForm.loading">{{userForm.active==3?'完 成':'下 一 步'}}</el-button>
      </div>
    </el-dialog>
    <!--图片预览-->
    <el-dialog :visible.sync="preview.show"><img width="100%" :src="preview.path"></el-dialog>
</section>
</template>

<script>
import * as api from '../api/index'
import {date,checkIDCard,checkMobile} from '../lib/function'
var validateMobile = (rule, value, callback) => {
    if (value==''||value==undefined) {
      callback(new Error('请输入手机号'));
    } else if(!checkMobile(value)){
      callback(new Error('手机号格式不正确'));
    }
    callback();
};
var validateIdNum = (rule, value, callback) => {
    if (value==''||value==undefined) {
      callback(new Error('请输入身份证号'));
    } else if(!checkIDCard(value)){
      callback(new Error('身份证号格式不正确'));
    }
    callback();
};
  export default {
	  name:'user',//页面名称
    data() {
      return {
    		m:'user',
    		show:false,//侧边栏显示与隐藏
    		query:{},//搜索数据
        select:[],
        progress:'',//进度
        sidebar:{//侧边栏
          show:false,
          curtab:'info',
          loading:false,
          id:0,
          info:{},
          bookList:[],
          progress:[],
          account:[]
        },
        preview:{show:false,path:''},//图片预览
        userForm:{//添加编辑教练的表单数据
          addShow:false,//弹窗显示状态
          editShow:false,//弹窗显示状态
          loading:false,
          active:1,
          data:{},//会员基本信息
          pay:{}//套餐及支付信息
        },
        rules1: {
          real_name: [
             { required: true, message: '请输入学员姓名', trigger: 'blur' }
            ],
          mobile:[
            { required: true, message: '请输入手机号', trigger: 'blur' },
            {validator:validateMobile,trigger: 'blur' },
          ],
          id_number:[
            { required: true, message: '请输入18位身份证号', trigger: 'blur' },
            { validator:validateIdNum, trigger: 'blur' }
          ]
        },
        rules2: {
          taocan_id: [
             { required: true, message: '请选择套餐', trigger: 'blur' }
            ],
          taocan_price: [
             { required: true, message: '请填写套餐价格', trigger: 'blur' }
            ],
          has_pay: [
             { required: true, message: '请填写本次实收金额', trigger: 'blur' }
           ],
          pay_type: [
             { required: true, message: '请选择支付方式', trigger: 'blur' }
            ]
        }
      }
    },
   watch: {
     '$parent.school.current.id':function(){
          this.$store.dispatch('taocan/getData',{})
      }
   },
	 computed:{
      listData(){
          return this.$store.state[this.m].data;
      },
      taocanData(){
        return this.$store.state.taocan.data;
      },
  		page(){
  			  return this.$store.state[this.m].page;
  		},
      list_loading(){
          return this.$store.state[this.m].list_loading;
      }
    },
    filters:{
      date,
      kemu(d){
          switch(parseInt(d)){
            case 0:return '未报名';break;
            case 1:return '科目一';break;
            case 2:return '科目二';break;
            case 3:return '科目三';break;
            case 4:return '科目四';break;
            case 100:return '已毕业';break;
            default:return '其它';
          }
      }
	  },
    methods: {
      removeFile(n){
        this.userForm.data.file[n]='';
        this.$forceUpdate();
      },
      uploadSuccess(res, file, fileList){
        if(res.status==1){
          let key=Object.keys(res.data)[0];
          if(this.userForm.data.file==undefined) this.userForm.data.file={};
          this.userForm.data.file[key]=res.data[key].path;
          this.$forceUpdate();
        }
      },
      imgPreview(file) {
       this.preview.path = file.url;
       this.preview.show = true;//是否预览
     },
     checkMobile(value){
       if(checkMobile(value)){
         api.user.checkUser({m:value},res=>{
             if(res.status==1) alert(res.info);
         });
       }
     },
      changeTaocan(id){
        let length=this.taocanData.length;
        for(let i=0;i<length;i++){
            if(this.taocanData[i].id==id) {
              this.userForm.pay.taocan_price=this.taocanData[i].price;
              this.userForm.pay.taocan_name=this.taocanData[i].title;
              break;
            }
        };
      },
      rowSelect(s){
        this.select=[];
        s.forEach((item)=>{
          this.select.push(item.id);
        });
      },
      changeProgress(kemu){
        if(this.select.length<=0) {
          this.$message.warning({message:'请先选择需要修改进度的学员'});
          this.progress='';
          return;
        }
        let a={0:'未报名',1:'科目一',2:'科目二',3:'科目三',4:'科目四',100:'已毕业'};
        this.$confirm('确定将已选中学员学车进度修改至【'+a[kemu]+'】?','提示',{confirmButtonText:'确定',cancelButtonText:'取消',type: 'warning'
           }).then(() => {
              api.user.modifyProgress({ids:this.select,kemu},res=>{
                if(res.status==1){
                  this.getData();
                  this.progress='';
                }else this.$notify.error(res);
              });
          }).catch(()=>{this.progress='';});
      },
      openSidebar(row, event, column){
        if(column==undefined||column.type!='default') return;
         this.sidebar.show=true;
         if(row.id!=this.sidebar.id){
           this.sidebar.id=row.id;
           this.sidebar.info={};
           this.sidebar.students=this.sidebar.bookList=this.sidebar.account=this.sidebar.log=[];
           this.getSideData(this.sidebar.curtab);
         }
      },
      closeSidebar(){this.sidebar.show=false},
      tabChange(e){
        this.sidebar.curtab=e.name;
        if(Object.keys(this.sidebar[e.name])<=0) {
            this.getSideData(e.name);
        }
      },
      getSideData(name){
        this.sidebar.loading=true;
        api[this.m][name]({id:this.sidebar.id},res=>{
           if(res.status==1){
              this.sidebar[name]=res.data;
           }else{
              this.$notify.error(res);
           }
             this.sidebar.loading=false;
        });
      },
      preStep(){
        switch(this.userForm.active){
            case 1:this.userForm.addShow=false;break;
            case 2:this.userForm.active=1;break;
            default:this.userForm.active=1;
        }
      },
      nextStep(){
        switch(this.userForm.active){
            case 1:
                this.submitUserForm('add');
                break;
            case 2:
                this.$refs.pay.validate(valid => {
                  if(valid){
                    this.userForm.loading=true;
                    api.user.baoming(this.userForm.pay,res=>{
                      if(res.status==1){
                        this.userForm.active=3;
                        this.getData();
                      }else {
                        this.$notify.error(res);
                      }
                      this.userForm.loading=false;
                    });
                  }else{
                    return false;
                  }
                });
                break;
            case 3:
                this.userForm.addShow=false;
                this.userForm.data=this.userForm.pay={};
                this.userForm.active=1;
                break;
        }
      },
      closeDialog(){
        this.userForm.data={};
      },
      editUser(){
          this.userForm.editShow=true;
          this.userForm.data=JSON.parse(JSON.stringify(this.sidebar.info));
       },
      submitUserForm(type) {//提交教练表单
        this.$refs[type].validate(valid => {
          if (valid) {
            this.userForm.loading=true;
            api.user[type](this.userForm.data,res=>{
                this.userForm.loading=false;
                if(res.status==1){
                  if(type=='edit') {
                    this.userForm[type+'Show']=false;
                    this.getSideData('info');
                    this.userForm.data={};
                    this.getData();
                  }
                  else {
                    this.userForm.active=2;
                    if(res.uid!=undefined) this.userForm.pay.uid=res.uid;
                  }
                }else{
                  this.$notify.error(res);
                }
            });
          } else {
            return false;
          }
        });
      },
      doSearch(){//查询数据
        this.query.p=1;
        this.getData();
      },
      sizeChange(size){
         this.query.pagesize=size;
         this.getData();
      },
      pageChange(p){
        this.query.p=p;
        this.getData();
      },
  	  getData(){//获取教练列表数据
  			this.$store.dispatch(
  			    this.m+'/getListData',
  				JSON.parse(JSON.stringify(this.query))
  			);
  		}
    },
	created(){
      if(this.$store.state[this.m].data<=0){
        this.query={};
        this.getData();
      }else{
        this.query=JSON.parse(JSON.stringify(this.$store.state[this.m].query));
      }
    }
  }
</script>
